//
//  BabyNameViewController.m
//  心水宝典
//
//  Created by zr on 2018/9/3.
//  Copyright © 2018年 zr. All rights reserved.
//

#import "BabyNameViewController.h"

@interface BabyNameViewController ()

@property (nonatomic, weak)UIImageView * backImageView;
@property (nonatomic, weak)UILabel * titleLabel;

@end

@implementation BabyNameViewController


- (void)viewWillAppear:(BOOL)animated{
    
    [[SuanNetWorkTool sharedTools] POST:@"/index/Liuhedivine/takename" parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
//        NSLog(@"res====%@",responseObject);
        
        NSDictionary * data = responseObject[@"data"];
        
        self.titleLabel.text = data[@"content"];
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
    }];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = WHITE_COLOR;
    
    [self setupNav];
    [self setupUI];
}


- (void)setupNav{
    
    self.title = @"八字合婚结果";
    
    UIButton * backButton = [[UIButton alloc] init];
    
    //    backButton.frame = CGRectMake(0, 0, 20 * SCREENH6, 20 * SCREENH6);
    backButton.size = CGSizeMake(20 * SCREENH6, 20 * SCREENH6);
    [backButton setImage:[UIImage imageNamed:@"fanhui"] forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(backToView) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem * leftButton = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    
    self.navigationItem.leftBarButtonItem = leftButton;
    
}


- (void)setupUI{
    
    UIImageView * backImageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
    
    backImageView.image = ImageNamed(@"bjaa");
    
    self.backImageView = backImageView;
    
    [self.view addSubview:self.backImageView];
    
    UILabel * titleLabel = [UILabel new];
    
    titleLabel.textColor = ColorWithRGB(0x8E6B44);
    titleLabel.font = [UIFont systemFontOfSize:15 * SCREENH6];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.numberOfLines = 0;
    
    self.titleLabel = titleLabel;
    
    [self.backImageView addSubview:self.titleLabel];
}


- (void)viewDidLayoutSubviews{
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.view).offset(33 * SCREENH6);
        make.trailing.mas_equalTo(self.view).offset(-33 * SCREENH6);
        make.centerX.mas_equalTo(self.view);
        make.centerY.mas_equalTo(self.view);
    }];
}

- (void)backToView {
    
    [self.navigationController popViewControllerAnimated:YES];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
